package com.cs.controller;


import com.cs.dto.ModelDto;
import com.cs.dto.Result;
import com.cs.req.ModelReq;
import com.cs.service.ModelService;
import com.cs.utils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 商品型号 前端控制器
 * </p>
 *
 * @author cs
 * @since 2021-08-05
 */
@Api("商品型号前端控制器")
@Slf4j
@RestController
@RequestMapping("/api/model")
public class ModelController {

    @Autowired
    private ModelService modelService;

    //条件查询带分页
    @ApiOperation("条件查询带分页")
    @GetMapping("search")
    public Result<Map<String,Object>>serch(ModelReq modelReq){
        Map<String,Object> map = modelService.search(modelReq);
        return ResultUtils.returnDataSuccess(map);
    }

    @GetMapping("{id}/detail")
    public Result<ModelDto> getModelDetailById(@PathVariable Long id){
        return ResultUtils.returnDataSuccess(modelService.getModelDetailById(id));
    }
}

